using HKB.Common;
using HKB.Data.Model;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace HKB.Data.Dal
{
	public class StockInfoOrder
	{
		public int GetMaxId()
		{
			return Conn.GetMaxID("InfoOrderID", "HLJXC_StockInfoOrder");
		}
		public bool Exists(int InfoOrderID)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("select count(1) from HLJXC_StockInfoOrder");
			stringBuilder.Append(" where InfoOrderID=@InfoOrderID");
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@InfoOrderID", SqlDbType.Int, 4)
			};
			array[0].Value = InfoOrderID;
			return Conn.Exists(stringBuilder.ToString(), array);
		}
		public int Add(HKB.Data.Model.StockInfoOrder model)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("insert into HLJXC_StockInfoOrder(");
			stringBuilder.Append("OrderID,InfoNumber,StockOrderType,StocktTypeID,StockStatus,Fee,PayableMoney,AlreadyPayableMoney,PayableEndDate,PayableDate,ReceiptMoney,AlreadyReceiptMoney,ReceiptEndDate,ReceiptDate,TotalMoney,CreateDate,UpdateDate,Inputer,Remark,OwnerID,StockDate)");
			stringBuilder.Append(" values (");
			stringBuilder.Append("@OrderID,@InfoNumber,@StockOrderType,@StocktTypeID,@StockStatus,@Fee,@PayableMoney,@AlreadyPayableMoney,@PayableEndDate,@PayableDate,@ReceiptMoney,@AlreadyReceiptMoney,@ReceiptEndDate,@ReceiptDate,@TotalMoney,@CreateDate,@UpdateDate,@Inputer,@Remark,@OwnerID,@StockDate)");
			stringBuilder.Append(";select @@IDENTITY");
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@OrderID", SqlDbType.Int, 4),
				new SqlParameter("@InfoNumber", SqlDbType.NVarChar, 50),
				new SqlParameter("@StockOrderType", SqlDbType.NVarChar, 50),
				new SqlParameter("@StocktTypeID", SqlDbType.Int, 4),
				new SqlParameter("@StockStatus", SqlDbType.Int, 4),
				new SqlParameter("@Fee", SqlDbType.Decimal, 9),
				new SqlParameter("@PayableMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@AlreadyPayableMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@PayableEndDate", SqlDbType.DateTime),
				new SqlParameter("@PayableDate", SqlDbType.DateTime),
				new SqlParameter("@ReceiptMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@AlreadyReceiptMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@ReceiptEndDate", SqlDbType.DateTime),
				new SqlParameter("@ReceiptDate", SqlDbType.DateTime),
				new SqlParameter("@TotalMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@CreateDate", SqlDbType.DateTime),
				new SqlParameter("@UpdateDate", SqlDbType.DateTime),
				new SqlParameter("@Inputer", SqlDbType.NVarChar, 50),
				new SqlParameter("@Remark", SqlDbType.NVarChar, 255),
				new SqlParameter("@OwnerID", SqlDbType.Int, 4),
				new SqlParameter("@StockDate", SqlDbType.DateTime)
			};
			array[0].Value = model.OrderID;
			array[1].Value = model.InfoNumber;
			array[2].Value = model.StockOrderType;
			array[3].Value = model.StocktTypeID;
			array[4].Value = model.StockStatus;
			array[5].Value = model.Fee;
			array[6].Value = model.PayableMoney;
			array[7].Value = model.AlreadyPayableMoney;
			array[8].Value = model.PayableEndDate;
			array[9].Value = model.PayableDate;
			array[10].Value = model.ReceiptMoney;
			array[11].Value = model.AlreadyReceiptMoney;
			array[12].Value = model.ReceiptEndDate;
			array[13].Value = model.ReceiptDate;
			array[14].Value = model.TotalMoney;
			array[15].Value = model.CreateDate;
			array[16].Value = model.UpdateDate;
			array[17].Value = model.Inputer;
			array[18].Value = model.Remark;
			array[19].Value = model.OwnerID;
			array[20].Value = model.StockDate;
			object single = Conn.GetSingle(stringBuilder.ToString(), array);
			int result;
			if (single == null)
			{
				result = 0;
			}
			else
			{
				result = System.Convert.ToInt32(single);
			}
			return result;
		}
		public int AddTransaction(HKB.Data.Model.StockInfoOrder model, Conn conn)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("insert into HLJXC_StockInfoOrder(");
			stringBuilder.Append("OrderID,InfoNumber,StockOrderType,StocktTypeID,StockStatus,Fee,PayableMoney,AlreadyPayableMoney,PayableEndDate,PayableDate,ReceiptMoney,AlreadyReceiptMoney,ReceiptEndDate,ReceiptDate,TotalMoney,CreateDate,UpdateDate,Inputer,Remark,OwnerID,StockDate)");
			stringBuilder.Append(" values (");
			stringBuilder.Append("@OrderID,@InfoNumber,@StockOrderType,@StocktTypeID,@StockStatus,@Fee,@PayableMoney,@AlreadyPayableMoney,@PayableEndDate,@PayableDate,@ReceiptMoney,@AlreadyReceiptMoney,@ReceiptEndDate,@ReceiptDate,@TotalMoney,@CreateDate,@UpdateDate,@Inputer,@Remark,@OwnerID,@StockDate)");
			stringBuilder.Append(" select SCOPE_IDENTITY()");
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@OrderID", SqlDbType.Int, 4),
				new SqlParameter("@InfoNumber", SqlDbType.NVarChar, 50),
				new SqlParameter("@StockOrderType", SqlDbType.NVarChar, 50),
				new SqlParameter("@StocktTypeID", SqlDbType.Int, 4),
				new SqlParameter("@StockStatus", SqlDbType.Int, 4),
				new SqlParameter("@Fee", SqlDbType.Decimal, 9),
				new SqlParameter("@PayableMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@AlreadyPayableMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@PayableEndDate", SqlDbType.DateTime),
				new SqlParameter("@PayableDate", SqlDbType.DateTime),
				new SqlParameter("@ReceiptMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@AlreadyReceiptMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@ReceiptEndDate", SqlDbType.DateTime),
				new SqlParameter("@ReceiptDate", SqlDbType.DateTime),
				new SqlParameter("@TotalMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@CreateDate", SqlDbType.DateTime),
				new SqlParameter("@UpdateDate", SqlDbType.DateTime),
				new SqlParameter("@Inputer", SqlDbType.NVarChar, 50),
				new SqlParameter("@Remark", SqlDbType.NVarChar, 255),
				new SqlParameter("@OwnerID", SqlDbType.Int, 4),
				new SqlParameter("@StockDate", SqlDbType.DateTime)
			};
			array[0].Value = model.OrderID;
			array[1].Value = model.InfoNumber;
			array[2].Value = model.StockOrderType;
			array[3].Value = model.StocktTypeID;
			array[4].Value = model.StockStatus;
			array[5].Value = model.Fee;
			array[6].Value = model.PayableMoney;
			array[7].Value = model.AlreadyPayableMoney;
			array[8].Value = model.PayableEndDate;
			array[9].Value = model.PayableDate;
			array[10].Value = model.ReceiptMoney;
			array[11].Value = model.AlreadyReceiptMoney;
			array[12].Value = model.ReceiptEndDate;
			array[13].Value = model.ReceiptDate;
			array[14].Value = model.TotalMoney;
			array[15].Value = model.CreateDate;
			array[16].Value = model.UpdateDate;
			array[17].Value = model.Inputer;
			array[18].Value = model.Remark;
			array[19].Value = model.OwnerID;
			array[20].Value = model.StockDate;
			object obj = conn.ExecuteTransactionScalar(stringBuilder.ToString(), array);
			int result;
			if (obj == null)
			{
				result = 0;
			}
			else
			{
				result = System.Convert.ToInt32(obj);
			}
			return result;
		}
		public bool UpdateTransaction(HKB.Data.Model.StockInfoOrder model, Conn conn)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("update HLJXC_StockInfoOrder set ");
			stringBuilder.Append("OrderID=@OrderID,");
			stringBuilder.Append("InfoNumber=@InfoNumber,");
			stringBuilder.Append("StockOrderType=@StockOrderType,");
			stringBuilder.Append("StocktTypeID=@StocktTypeID,");
			stringBuilder.Append("StockStatus=@StockStatus,");
			stringBuilder.Append("Fee=@Fee,");
			stringBuilder.Append("PayableMoney=@PayableMoney,");
			stringBuilder.Append("AlreadyPayableMoney=@AlreadyPayableMoney,");
			stringBuilder.Append("PayableEndDate=@PayableEndDate,");
			stringBuilder.Append("PayableDate=@PayableDate,");
			stringBuilder.Append("ReceiptMoney=@ReceiptMoney,");
			stringBuilder.Append("AlreadyReceiptMoney=@AlreadyReceiptMoney,");
			stringBuilder.Append("ReceiptEndDate=@ReceiptEndDate,");
			stringBuilder.Append("ReceiptDate=@ReceiptDate,");
			stringBuilder.Append("TotalMoney=@TotalMoney,");
			stringBuilder.Append("CreateDate=@CreateDate,");
			stringBuilder.Append("UpdateDate=@UpdateDate,");
			stringBuilder.Append("Inputer=@Inputer,");
			if (!string.IsNullOrEmpty(model.OwnerID.ToString()))
			{
				stringBuilder.Append("OwnerID=" + model.OwnerID + ",");
			}
			if (model.StockDate.HasValue)
			{
				stringBuilder.Append("StockDate='" + model.StockDate + "',");
			}
			stringBuilder.Append("Remark=@Remark");
			stringBuilder.Append(" where InfoOrderID=@InfoOrderID");
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@OrderID", SqlDbType.Int, 4),
				new SqlParameter("@InfoNumber", SqlDbType.NVarChar, 50),
				new SqlParameter("@StockOrderType", SqlDbType.NVarChar, 50),
				new SqlParameter("@StocktTypeID", SqlDbType.Int, 4),
				new SqlParameter("@StockStatus", SqlDbType.Int, 4),
				new SqlParameter("@Fee", SqlDbType.Decimal, 9),
				new SqlParameter("@PayableMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@AlreadyPayableMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@PayableEndDate", SqlDbType.DateTime),
				new SqlParameter("@PayableDate", SqlDbType.DateTime),
				new SqlParameter("@ReceiptMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@AlreadyReceiptMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@ReceiptEndDate", SqlDbType.DateTime),
				new SqlParameter("@ReceiptDate", SqlDbType.DateTime),
				new SqlParameter("@TotalMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@CreateDate", SqlDbType.DateTime),
				new SqlParameter("@UpdateDate", SqlDbType.DateTime),
				new SqlParameter("@Inputer", SqlDbType.NVarChar, 50),
				new SqlParameter("@Remark", SqlDbType.NVarChar, 255),
				new SqlParameter("@InfoOrderID", SqlDbType.Int, 4)
			};
			array[0].Value = model.OrderID;
			array[1].Value = model.InfoNumber;
			array[2].Value = model.StockOrderType;
			array[3].Value = model.StocktTypeID;
			array[4].Value = model.StockStatus;
			array[5].Value = model.Fee;
			array[6].Value = model.PayableMoney;
			array[7].Value = model.AlreadyPayableMoney;
			array[8].Value = model.PayableEndDate;
			array[9].Value = model.PayableDate;
			array[10].Value = model.ReceiptMoney;
			array[11].Value = model.AlreadyReceiptMoney;
			array[12].Value = model.ReceiptEndDate;
			array[13].Value = model.ReceiptDate;
			array[14].Value = model.TotalMoney;
			array[15].Value = model.CreateDate;
			array[16].Value = model.UpdateDate;
			array[17].Value = model.Inputer;
			array[18].Value = model.Remark;
			array[19].Value = model.InfoOrderID;
			int num = conn.ExecuteTransaction(stringBuilder.ToString(), array);
			return num > 0;
		}
		public bool Update(HKB.Data.Model.StockInfoOrder model)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("update HLJXC_StockInfoOrder set ");
			stringBuilder.Append("OrderID=@OrderID,");
			stringBuilder.Append("InfoNumber=@InfoNumber,");
			stringBuilder.Append("StockOrderType=@StockOrderType,");
			stringBuilder.Append("StocktTypeID=@StocktTypeID,");
			stringBuilder.Append("StockStatus=@StockStatus,");
			stringBuilder.Append("Fee=@Fee,");
			stringBuilder.Append("PayableMoney=@PayableMoney,");
			stringBuilder.Append("AlreadyPayableMoney=@AlreadyPayableMoney,");
			stringBuilder.Append("PayableEndDate=@PayableEndDate,");
			stringBuilder.Append("PayableDate=@PayableDate,");
			stringBuilder.Append("ReceiptMoney=@ReceiptMoney,");
			stringBuilder.Append("AlreadyReceiptMoney=@AlreadyReceiptMoney,");
			stringBuilder.Append("ReceiptEndDate=@ReceiptEndDate,");
			stringBuilder.Append("ReceiptDate=@ReceiptDate,");
			stringBuilder.Append("TotalMoney=@TotalMoney,");
			stringBuilder.Append("CreateDate=@CreateDate,");
			stringBuilder.Append("UpdateDate=@UpdateDate,");
			stringBuilder.Append("Inputer=@Inputer,");
			if (!string.IsNullOrEmpty(model.OwnerID.ToString()))
			{
				stringBuilder.Append("OwnerID=" + model.OwnerID + ",");
			}
			if (model.StockDate.HasValue)
			{
				stringBuilder.Append("StockDate='" + model.StockDate + "',");
			}
			stringBuilder.Append("Remark=@Remark");
			stringBuilder.Append(" where InfoOrderID=@InfoOrderID");
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@OrderID", SqlDbType.Int, 4),
				new SqlParameter("@InfoNumber", SqlDbType.NVarChar, 50),
				new SqlParameter("@StockOrderType", SqlDbType.NVarChar, 50),
				new SqlParameter("@StocktTypeID", SqlDbType.Int, 4),
				new SqlParameter("@StockStatus", SqlDbType.Int, 4),
				new SqlParameter("@Fee", SqlDbType.Decimal, 9),
				new SqlParameter("@PayableMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@AlreadyPayableMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@PayableEndDate", SqlDbType.DateTime),
				new SqlParameter("@PayableDate", SqlDbType.DateTime),
				new SqlParameter("@ReceiptMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@AlreadyReceiptMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@ReceiptEndDate", SqlDbType.DateTime),
				new SqlParameter("@ReceiptDate", SqlDbType.DateTime),
				new SqlParameter("@TotalMoney", SqlDbType.Decimal, 9),
				new SqlParameter("@CreateDate", SqlDbType.DateTime),
				new SqlParameter("@UpdateDate", SqlDbType.DateTime),
				new SqlParameter("@Inputer", SqlDbType.NVarChar, 50),
				new SqlParameter("@Remark", SqlDbType.NVarChar, 255),
				new SqlParameter("@InfoOrderID", SqlDbType.Int, 4)
			};
			array[0].Value = model.OrderID;
			array[1].Value = model.InfoNumber;
			array[2].Value = model.StockOrderType;
			array[3].Value = model.StocktTypeID;
			array[4].Value = model.StockStatus;
			array[5].Value = model.Fee;
			array[6].Value = model.PayableMoney;
			array[7].Value = model.AlreadyPayableMoney;
			array[8].Value = model.PayableEndDate;
			array[9].Value = model.PayableDate;
			array[10].Value = model.ReceiptMoney;
			array[11].Value = model.AlreadyReceiptMoney;
			array[12].Value = model.ReceiptEndDate;
			array[13].Value = model.ReceiptDate;
			array[14].Value = model.TotalMoney;
			array[15].Value = model.CreateDate;
			array[16].Value = model.UpdateDate;
			array[17].Value = model.Inputer;
			array[18].Value = model.Remark;
			array[19].Value = model.InfoOrderID;
			int num = Conn.ExecuteSql(stringBuilder.ToString(), array);
			return num > 0;
		}
		public bool Delete(int InfoOrderID)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("delete from HLJXC_StockInfoOrder ");
			stringBuilder.Append(" where InfoOrderID=@InfoOrderID");
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@InfoOrderID", SqlDbType.Int, 4)
			};
			array[0].Value = InfoOrderID;
			int num = Conn.ExecuteSql(stringBuilder.ToString(), array);
			return num > 0;
		}
		public bool DeleteList(string InfoOrderIDlist)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("delete from HLJXC_StockInfoOrder ");
			stringBuilder.Append(" where InfoOrderID in (" + InfoOrderIDlist + ")  ");
			int num = Conn.ExecuteSql(stringBuilder.ToString(), new IDbDataParameter[0]);
			return num > 0;
		}
		public HKB.Data.Model.StockInfoOrder GetModel(int InfoOrderID)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("select  top 1 * from HLJXC_StockInfoOrder ");
			stringBuilder.Append(" where InfoOrderID=@InfoOrderID");
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@InfoOrderID", SqlDbType.Int, 4)
			};
			array[0].Value = InfoOrderID;
			HKB.Data.Model.StockInfoOrder stockInfoOrder = new HKB.Data.Model.StockInfoOrder();
			DataSet dataSet = Conn.Query(stringBuilder.ToString(), array);
			HKB.Data.Model.StockInfoOrder result;
			if (dataSet.Tables[0].Rows.Count > 0)
			{
				result = this.DataRowToModel(dataSet.Tables[0].Rows[0]);
			}
			else
			{
				result = null;
			}
			return result;
		}
		public HKB.Data.Model.StockInfoOrder DataRowToModel(DataRow row)
		{
			HKB.Data.Model.StockInfoOrder stockInfoOrder = new HKB.Data.Model.StockInfoOrder();
			if (row != null)
			{
				if (row["InfoOrderID"] != null && row["InfoOrderID"].ToString() != "")
				{
					stockInfoOrder.InfoOrderID = int.Parse(row["InfoOrderID"].ToString());
				}
				if (row["OrderID"] != null && row["OrderID"].ToString() != "")
				{
					stockInfoOrder.OrderID = new int?(int.Parse(row["OrderID"].ToString()));
				}
				if (row["InfoNumber"] != null)
				{
					stockInfoOrder.InfoNumber = row["InfoNumber"].ToString();
				}
				if (row["StockOrderType"] != null)
				{
					stockInfoOrder.StockOrderType = row["StockOrderType"].ToString();
				}
				if (row["StocktTypeID"] != null && row["StocktTypeID"].ToString() != "")
				{
					stockInfoOrder.StocktTypeID = new int?(int.Parse(row["StocktTypeID"].ToString()));
				}
				if (row["StockStatus"] != null && row["StockStatus"].ToString() != "")
				{
					stockInfoOrder.StockStatus = new int?(int.Parse(row["StockStatus"].ToString()));
				}
				if (row["Fee"] != null && row["Fee"].ToString() != "")
				{
					stockInfoOrder.Fee = new decimal?(decimal.Parse(row["Fee"].ToString()));
				}
				if (row["PayableMoney"] != null && row["PayableMoney"].ToString() != "")
				{
					stockInfoOrder.PayableMoney = new decimal?(decimal.Parse(row["PayableMoney"].ToString()));
				}
				if (row["AlreadyPayableMoney"] != null && row["AlreadyPayableMoney"].ToString() != "")
				{
					stockInfoOrder.AlreadyPayableMoney = new decimal?(decimal.Parse(row["AlreadyPayableMoney"].ToString()));
				}
				if (row["PayableEndDate"] != null && row["PayableEndDate"].ToString() != "")
				{
					stockInfoOrder.PayableEndDate = new System.DateTime?(System.DateTime.Parse(row["PayableEndDate"].ToString()));
				}
				if (row["PayableDate"] != null && row["PayableDate"].ToString() != "")
				{
					stockInfoOrder.PayableDate = new System.DateTime?(System.DateTime.Parse(row["PayableDate"].ToString()));
				}
				if (row["ReceiptMoney"] != null && row["ReceiptMoney"].ToString() != "")
				{
					stockInfoOrder.ReceiptMoney = new decimal?(decimal.Parse(row["ReceiptMoney"].ToString()));
				}
				if (row["AlreadyReceiptMoney"] != null && row["AlreadyReceiptMoney"].ToString() != "")
				{
					stockInfoOrder.AlreadyReceiptMoney = new decimal?(decimal.Parse(row["AlreadyReceiptMoney"].ToString()));
				}
				if (row["ReceiptEndDate"] != null && row["ReceiptEndDate"].ToString() != "")
				{
					stockInfoOrder.ReceiptEndDate = new System.DateTime?(System.DateTime.Parse(row["ReceiptEndDate"].ToString()));
				}
				if (row["ReceiptDate"] != null && row["ReceiptDate"].ToString() != "")
				{
					stockInfoOrder.ReceiptDate = new System.DateTime?(System.DateTime.Parse(row["ReceiptDate"].ToString()));
				}
				if (row["TotalMoney"] != null && row["TotalMoney"].ToString() != "")
				{
					stockInfoOrder.TotalMoney = new decimal?(decimal.Parse(row["TotalMoney"].ToString()));
				}
				if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
				{
					stockInfoOrder.CreateDate = new System.DateTime?(System.DateTime.Parse(row["CreateDate"].ToString()));
				}
				if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "")
				{
					stockInfoOrder.UpdateDate = new System.DateTime?(System.DateTime.Parse(row["UpdateDate"].ToString()));
				}
				if (row["Inputer"] != null)
				{
					stockInfoOrder.Inputer = row["Inputer"].ToString();
				}
				if (row["Remark"] != null)
				{
					stockInfoOrder.Remark = row["Remark"].ToString();
				}
				if (row["OwnerID"] != System.DBNull.Value)
				{
					stockInfoOrder.OwnerID = System.Convert.ToInt32(row["OwnerID"].ToString());
				}
			}
			return stockInfoOrder;
		}
		public DataSet GetList(string strWhere)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("select * FROM HLJXC_StockInfoOrder ");
			if (strWhere.Trim() != "")
			{
				stringBuilder.Append(" where " + strWhere);
			}
			return Conn.Query(stringBuilder.ToString(), new IDbDataParameter[0]);
		}
		public DataSet GetList(int Top, string strWhere, string filedOrder)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("select ");
			if (Top > 0)
			{
				stringBuilder.Append(" top " + Top.ToString());
			}
			stringBuilder.Append(" * FROM HLJXC_StockInfoOrder ");
			if (strWhere.Trim() != "")
			{
				stringBuilder.Append(" where " + strWhere);
			}
			stringBuilder.Append(" order by " + filedOrder);
			return Conn.Query(stringBuilder.ToString(), new IDbDataParameter[0]);
		}
		public int GetRecordCount(string strWhere)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("select count(1) FROM HLJXC_StockInfoOrder ");
			if (strWhere.Trim() != "")
			{
				stringBuilder.Append(" where " + strWhere);
			}
			object single = DbHelperSQL.GetSingle(stringBuilder.ToString());
			int result;
			if (single == null)
			{
				result = 0;
			}
			else
			{
				result = System.Convert.ToInt32(single);
			}
			return result;
		}
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			stringBuilder.Append("SELECT * FROM ( ");
			stringBuilder.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				stringBuilder.Append("order by T." + orderby);
			}
			else
			{
				stringBuilder.Append("order by T.InfoOrderID desc");
			}
			stringBuilder.Append(")AS Row, T.*  from HLJXC_StockInfoOrder T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				stringBuilder.Append(" WHERE " + strWhere);
			}
			stringBuilder.Append(" ) TT");
			stringBuilder.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return Conn.Query(stringBuilder.ToString(), new IDbDataParameter[0]);
		}
		public DataSet GetStockInfoOrderByStockOrderID(int StockOrderID)
		{
			string text = " sio.InfoOrderID,sio.InfoNumber,sio.CreateDate,sio.Fee,sio.ReceiptMoney,sio.AlreadyReceiptMoney,MoneyGoods,Deliver_TotalPrice,Invoice_TotalPrice,MoneyTotal,o.TradeType ";
			string text2 = string.Concat(new object[]
			{
				"select ",
				text,
				" from HLJXC_StockInfoOrder as sio,HLShop_Order as o where sio.OrderID=o.OrderFormID and sio.InfoOrderID in  (",
				StockOrderID,
				")"
			});
			return Conn.Query(text2.ToString(), new IDbDataParameter[0]);
		}
		public DataTable GetStockOrderInfoItemListBySqlWhere(string strSQLWhere)
		{
			string text = "select * from View_JXC_StockOrderInfoItem " + strSQLWhere;
			return Conn.Query(text.ToString(), new IDbDataParameter[0]).Tables[0];
		}
		public int GetStockOrderInfoItemListRecordCount(string strSQLWhere)
		{
			Conn conn = new Conn();
			string sql = "select COUNT(*) from View_JXC_StockOrderInfoItem " + strSQLWhere;
			return conn.ExecuteCount(sql);
		}
		public DataTable GetStockOrderInfoItemListPage(string strSQLWhere, string OrderBy, int startIndex, int endIndex)
		{
			if (string.IsNullOrEmpty(OrderBy))
			{
				OrderBy = "order by InfoOrderID desc";
			}
			string text = "select ROW_NUMBER() OVER (" + OrderBy + ") as row,* from View_JXC_StockOrderInfoItem " + strSQLWhere;
			string text2 = string.Concat(new object[]
			{
				"SELECT * FROM ( ",
				text,
				" ) as TT WHERE TT.row between ",
				startIndex,
				" and ",
				endIndex
			});
			return Conn.Query(text2.ToString(), new IDbDataParameter[0]).Tables[0];
		}
		public DataTable GetListInfoItemProductByInfoOrderID(int infoOrderID)
		{
			string text = "select * from View_JXC_StockOrderInfoItemProduct where InfoOrderID=" + infoOrderID;
			return Conn.Query(text.ToString(), new IDbDataParameter[0]).Tables[0];
		}
		public DataTable GetListInfoItemProduct(string strSQLWhere)
		{
			string text = "select * from View_JXC_StockOrderInfoItemProduct" + strSQLWhere;
			return Conn.Query(text.ToString(), new IDbDataParameter[0]).Tables[0];
		}
		public int GetListInfoItemProductRecordCount(string strSQLWhere)
		{
			Conn conn = new Conn();
			string sql = "select COUNT(*) from View_JXC_StockOrderInfoItemProduct " + strSQLWhere;
			return conn.ExecuteCount(sql);
		}
		public DataTable GetListInfoItemProductPage(string strSQLWhere, string OrderBy, int startIndex, int endIndex)
		{
			if (string.IsNullOrEmpty(OrderBy))
			{
				OrderBy = "order by InfoOrderID desc";
			}
			string text = "select ROW_NUMBER() OVER (" + OrderBy + ") as row,* from View_JXC_StockOrderInfoItemProduct " + strSQLWhere;
			string text2 = string.Concat(new object[]
			{
				"SELECT * FROM ( ",
				text,
				" ) as TT WHERE TT.row between ",
				startIndex,
				" and ",
				endIndex
			});
			return Conn.Query(text2.ToString(), new IDbDataParameter[0]).Tables[0];
		}
	}
}
